package com.demo.serviceImpl;

import java.util.List;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.demo.entity.Student;
import com.demo.entity.StudentExample;
import com.demo.entity.StudentInfo;
import com.demo.mapper.StudentMapper;
import com.demo.service.StudentService;
@Service
public class StudentServiceImpl implements StudentService{
	@Autowired
	private StudentMapper studentMapper;
	
	@Override
	public int addStudent(Student stu)  throws Exception{
		
		return studentMapper.insert(stu);
	}

	@Override
	public Student selectStudentById(String id) throws Exception {
		
		return  studentMapper.selectByPrimaryKey(id);
 	}

	@Override
	public int deleteStudentById(String id)  throws Exception{
		
		return studentMapper.deleteByPrimaryKey(id);
	}

	@Override
	public int updateStudent(Student stu) throws Exception {

		return studentMapper.updateByPrimaryKeySelective(stu);
	}

	@Override
	public List<Student> selectAllStudent() throws Exception {
		
		StudentExample studentExample = new StudentExample();
		
		return studentMapper.selectByExample(studentExample);
	}
	public List<Student> selectAllStudentInfo()throws Exception{
		return studentMapper.selectAllStudentInfoInnerClass();
	}

	@Override
	public List<StudentInfo> selectAllStudentInfoE() throws Exception {
		return studentMapper.selectAllStudentInfo();
	}

	@Override
	public List<StudentInfo> selectStudentByNamesId(StudentInfo studentInfo) throws Exception {
		return studentMapper.findStudentByNames(studentInfo);
	}
}
